#include <iostream>
using namespace std;
#define N 5

int main() {
  int arr[N + 5], sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> arr[i];
  }
  for (int i = 0; i < N; i++) {
    sum += arr[i] % 3;
    int rest = arr[i] / 3;
    arr[i] = rest;
    arr[(i + N - 1) % N] += rest;
    arr[(i + 1) % N] += rest;
  }
  for (int i = 0; i < N; i++) {
    if (i != 0) {
      cout << " ";
    }
    cout << arr[i];
  }
  cout << endl;
  cout << sum << endl;
  return 0;
}